package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.RoleBean;
import com.project.mapper.IRoleMapper;
import com.project.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private IRoleService service;

    @RequestMapping("findAll")
    public List<RoleBean> findAll(){
        return service.findAll();
    }

    @RequestMapping("cutAll")
    public IPage<RoleBean> cutAll(int pageNo){
        return service.cutAll(pageNo);
    }

    @RequestMapping("del")
    public String del(int id){
        System.out.println(id);
        service.del(id);
        return "ok";
    }

    @RequestMapping("add")
    public String add(RoleBean role,int[] gradeArray){
        service.add(role, gradeArray);
        return "ok";
    }

    @RequestMapping("findById")
    public RoleBean findById(int id){
        return service.findById(id);
    }

    @RequestMapping("update")
    public String update(int id,int[] gradeArray){
        service.update(id, gradeArray);
        System.out.println("564654564");
        return "ok";
    }
}
